import prompt from '@system.prompt';
import router from '@system.router';
import tabbarData from '../../../common/tarbardata.js'
export default {
    data:{

            selectList:["地震","火灾","洪水","泥石流"],
            distroychengdu:1,
            disastercat:"地震",
            detail:'',

//            judgee:this.$app.$def.globalData.judgee,
//            tabbardata:tabbarData,
            timecur:'',
            judgeea:1,
//            judgeea1:1
    },
    //响应下拉框选择事件
    selectChange(e){

        for(let i = 0;i<this.selectList.length;i++){
            if(e.newValue == this.selectList[i]){
                console.log(e.newValue);

                console.log(e.newValue);
                this.disastercat=e.newValue;
            }
        }
    },
    //单选框选择
    onRadioChange1(inputValue, e) {
        //        console.info(inputValue);
        if(e.checked){
            console.info("房屋有少量裂纹");
            this.distroychengdu=1;
        }
    },
    onRadioChange2(inputValue, e) {
        //        console.info(inputValue);
        if(e.checked){
            console.info("房屋有大量裂纹");
            this.distroychengdu=2;
        }
    },
    onRadioChange3(inputValue, e) {
        //        console.info(inputValue);
        if(e.checked){
            console.info("一到三间房屋倒塌");
            this.distroychengdu=3;
        }
    },
    onRadioChange4(inputValue, e) {
        //        console.info(inputValue);
        if(e.checked){
            console.info("三间以上房屋倒塌");
            this.distroychengdu=4;
        }
    },
    //响应文本框输入
    handleTextInput(e){
        this.detail=e.value;
        console.log(this.detail);
    },
    //进入拍照过程
    handleChooseImg(){
//        this.$app.$def.globalData.judgee=1;
        router.push({
            uri:'pages/homepage/cameraa/cameraa',
            params:{
                routenum:1
            }
        })
    },
    //将用户填写的信息上传到数据库中
    fankui:async function(){
        if(this.judgeea==1){
            prompt.showToast({
                message: '请上传图片',
                duration: 2000,
            });
        }else{
            prompt.showToast({
                message: '提交成功',
                duration: 2000,
            });
            setTimeout(()=>{
                router.push({
                    uri:'pages/firstpage/firstpage',
////                    params:{
////                        tabbardata:this.tabbardata,
////                    }
                })
            },2000);
            var time=new Date();
            this.timecur=time.getFullYear()+"/"+(time.getMonth()+1)+"/"+time.getDate()+"   "+time.toLocaleTimeString();
            var actionData = {};
            actionData.category = "房屋破坏";
            actionData.disastercat = this.disastercat;
            actionData.distroychengdu = this.distroychengdu;
            actionData.timec = this.timecur;


            var action = {};

            //添加service所在的包名
            action.bundleName = 'com.example.myapplication4';

            //添加service的类名
            action.abilityName = 'com.example.myapplication4.DemoService5';

            //添加messageCode ，用于区分其他的action
            action.messageCode = 300;

            //添加数据
            action.data = actionData;

            //跳转的activity的类型，0代表service
            action.abilityType = 0;

            //最重要的一步：跳转
            var str = await FeatureAbility.callAbility(action);

            //下面是处理 java FA 返回的数据
            var result = JSON.parse(str);
            console.log(result.ans);
        }
    },
}
